<?php use_javascript('approval/requestform.js') ?>

<script type="text/javascript">
    $(document).ready(function(){

        setStatusHandler();
    })
</script>

<?php if(
        $research->isResearchStatus(Types::$RESEARCH_APPROVAL_STATUS[Types::$APPR_NEW]) ||
        $research->isResearchStatus(Types::$RESEARCH_APPROVAL_STATUS[Types::$APPR_REVISION])
        ) : ?>
    <?php include_component('approval', 'requestForm', array('research' => $research)) ?>
<?php endif; ?>

<div id="research_status" class="ui-widget-content ui-state-highlight">
    <div style="width: 100%" >
        <?php if($research->isResearchStatus(Types::$RESEARCH_APPROVAL_STATUS[Types::$APPR_NEW])) : ?>
            Are you ready to make your data available for public? <div id="ask" class="link-div">Ask a reviewer</div> to approve.

        <?php elseif($research->isResearchStatus(Types::$RESEARCH_APPROVAL_STATUS[Types::$APPR_REVISION])) : ?>
            <?php if ($sf_user->getAttribute('currentuser')->id == $research->approvalauthorityid): ?>
                Revision is needed for this research.
            <?php else : ?>
                <?php echo $prof->firstname.' '.$prof->lastname ?> asked to revise your data. <div id="ask" class="link-div">Ask</div> for next review.
            <?php endif; ?>

        <?php elseif($research->isResearchStatus(Types::$RESEARCH_APPROVAL_STATUS[Types::$APPR_AWAITING])): ?>

            <?php if ($sf_user->getAttribute('currentuser')->id == $research->approvalauthorityid): ?>
                This research is waiting for your approval. Click <div id="review" class="link-div">here</div> to start a review.
                <form id="review_form" method="post" action="<?php echo url_for('approval/review?researchid='.$research->id) ?>">
                </form>
            <?php else: ?>
                Your research is waiting for <?php echo $prof->firstname.' '.$prof->lastname ?>'s approval.
            <?php endif; ?>

        <?php elseif($research->isResearchStatus(Types::$RESEARCH_APPROVAL_STATUS[Types::$APPR_REVIEWING])): ?>

            <?php if ($sf_user->getAttribute('currentuser')->id == $research->approvalauthorityid): ?>
                Finished reviewing this research? <div id="publish" class="link-div">Publish</div> or <div id="revision" class="link-div">Need a revision</div>.
                <form id="publish_form" method="post" action="<?php echo url_for('approval/publish?researchid='.$research->id) ?>">
                </form>
                <form id="revision_form" method="post" action="<?php echo url_for('approval/revise?researchid='.$research->id) ?>">
                </form>
            <?php else: ?>
                <?php echo $prof->firstname.' '.$prof->lastname ?> is reviewing your research.
            <?php endif; ?>

        <?php elseif($research->isResearchStatus(Types::$RESEARCH_APPROVAL_STATUS[Types::$APPR_APPROVED])): ?>
            This research is already approved by <?php echo $prof->firstname.' '.$prof->lastname ?>.

        <?php else: ?>
            <!--        Ready to publish your data? <div id="ask" class="link-div">Ask your professor</div> to review.-->
            Undefined research status.
            
        <?php endif; ?>
    </div>
</div>